#include "include/transaction_record.hpp"

TransactionRecord::TransactionRecord(const QString &stockCode,
                                     const QString &stockName, Type type,
                                     int shares, double price,
                                     const QDateTime &time)
    : m_stockCode(stockCode), m_stockName(stockName), m_type(type),
      m_shares(shares), m_price(price), m_time(time) {
  // 计算交易总额
  m_total = m_price * m_shares;
}

QString TransactionRecord::getStockCode() const { return m_stockCode; }

QString TransactionRecord::getStockName() const { return m_stockName; }

TransactionRecord::Type TransactionRecord::getType() const { return m_type; }

QString TransactionRecord::getTypeString() const {
  return m_type == Type::Buy ? "买入" : "卖出";
}

int TransactionRecord::getShares() const { return m_shares; }

double TransactionRecord::getPrice() const { return m_price; }

double TransactionRecord::getTotal() const { return m_total; }

QDateTime TransactionRecord::getTime() const { return m_time; }
